<template>
  <component :is="currentType" v-bind="$attrs" @input="updateValue" />
</template>

<script>
import tree from './tree';
import roles from './roles';

export default {
  components: {
    tree,
    roles
  },
  props: {
    type: {
      type: String,
      default: 'tree'
    }
  },
  computed: {
    currentType() {
      if (['roles', 'tree'].includes(this.type)) {
        return this.type;
      }
      return 'tree';
    },
  },
  methods: {
    updateValue(newValue) {
      this.$emit("input", newValue);
    },
  }
}
</script>